package com.coincalf.web;

import com.coincalf.framework.http.Response;
import com.coincalf.framework.security.UserDetails;
import com.coincalf.service.AccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Authorization;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.sound.midi.Soundbank;
import java.util.Map;

/**
 * @Description: 数字货币充值 Controller
 * @Author: Chen Long
 * @Date: Created in 2018/5/22 下午5:21
 * @Modified by: Chen Long
 */
@RestController
@RequestMapping("/recharge")
@Slf4j
@Api(value = "资产管理-充值", description = "资产管理-充值")
public class CoinRechargeController {

    @Autowired
    private AccountService accountService;
    @Autowired
    private CommonController commonController;

    /**
     * 获取充值地址
     */
    @GetMapping("/address/{coinId}")
    @ApiOperation(value = "COIN-RECHARGE-001 获取充值地址", notes = "获取充值地址", httpMethod = "GET")
    @ApiImplicitParam(name = "coinId", value = "币种ID", dataType = "String", paramType = "path")
    //@PreAuthorize("isAuthenticated()")
    public Object rechargeAddress(
            HttpServletRequest request,
            @PathVariable("coinId") Long coinId
    ) {
        Long userId = commonController.getUserId(request);
        Map map = accountService.queryRechargeAddress(coinId, userId);
        return Response.ok(map);
    }

}
